<html>
<head><meta charset="utf-8"><title>Extern crate in mock analysis? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extern.20crate.20in.20mock.20analysis.3F.html">Extern crate in mock analysis?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206356323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extern%20crate%20in%20mock%20analysis%3F/near/206356323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extern.20crate.20in.20mock.20analysis.3F.html#206356323">(Aug 08 2020 at 17:18)</a>:</h4>
<p>I've implemented syntax highlighting, hover and goto for <code>extern crate</code> (mostly because it all goes through <code>classify_name</code> and <code>classify_name_ref</code>), but I'm unable to figure out how to test the syntax highlighting portion. I've verified it works manually, but I can't see how to explain to <code>MockAnalysis</code> that there are external crates. Is that supported, or would I need to add that functionality to <code>MockAnalysis</code> to move forward?</p>



<a name="206356736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extern%20crate%20in%20mock%20analysis%3F/near/206356736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extern.20crate.20in.20mock.20analysis.3F.html#206356736">(Aug 08 2020 at 17:32)</a>:</h4>
<p>Just figured it out by reading more into <code>MockAnalysis</code> (and for anyone looking for this in the future, you need to:</p>
<ul>
<li>Add a line <code>//- /main.rs</code> as the first "file" with the code you want to be the main focus of the test</li>
<li>Add modules with:<ul>
<li>The crate name as the dir, e.g. `//- /crate_name_here/...</li>
<li>The crate's must have a root ending in <code>lib.rs</code>, e.g. <code>//- /crate_name_here/lib.rs</code></li>
</ul>
</li>
<li>Order matters, placing the crates above <code>//- /main.rs</code> did not work for me</li>
</ul>
<div class="codehilite"><pre><span></span><code>        //- /main.rs
        extern crate std;
        extern crate alloc as abc;
        //- /std/lib.rs
        pub struct S;
        //- /alloc/lib.rs
        pub struct A
</code></pre></div>



<a name="206675999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Extern%20crate%20in%20mock%20analysis%3F/near/206675999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Extern.20crate.20in.20mock.20analysis.3F.html#206675999">(Aug 12 2020 at 09:49)</a>:</h4>
<p>Yup, there's more or less the single format for fixtures now, with <code>//-</code> markers</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>